

//webpack  基本配置文件

//打包(入口  出口 环境配置)
//模块化开发

//Js/Ts
//CSS/Less/Scss
//png/jpg
//json
//Vue
//React

//配置服务器  devServer
//SourceMap
//Plugins 插件


const path = require('path')
const webpack = require('webpack')
const OpenBrowserPlugin = require('webpack-open-browser-plugin')
const htmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
    mode: "development",  //development开发环境 production 生产环境 test 测试环境
    entry: ['./src/main.js'],//入口
    output: {
        path: path.resolve(__dirname, 'dist'), //路径
        filename: './js/[name].[chunkhash:8].js',//长度为8的随机加密字符串
        publicPath: ''
    },
    //配置服务器
    devServer: {
        host: "0.0.0.0",
        port: 8000,
        open: false,
        compress: true,
        hot: true,
        proxy: {//代理

        },
        static: {
            directory: path.join(__dirname, 'public'),
        },
    },
    module: {

    },

    //插件 数组用法
    plugins: [
        new webpack.HotModuleReplacementPlugin(),//热替换模块确定使用
        new OpenBrowserPlugin({
            url: 'http://localhost:8000'
        }),
        new htmlWebpackPlugin({
            template: './public/index.html',//打包的html 文件路径
            minify: true,//压缩
            inject: true,//自动注入js和css
        }),
    ]
}